package de.baumann.browser.model;


import java.math.BigDecimal;
import java.util.List;

import de.baumann.browser.api.net.util.OtherHttpUtil;
import de.baumann.browser.api.net.util.OrderHttpUtil;
import de.baumann.browser.api.net.util.UserHttpUtil;
import de.baumann.browser.api.net.vo.Order;
import de.baumann.browser.api.net.vo.PayParam;
import de.baumann.browser.api.net.vo.RechargeInfo;
import de.baumann.browser.api.net.vo.Result;
import de.baumann.browser.rx.RxSchedulers;
import de.baumann.browser.utils.MD5Util;
import io.reactivex.Observable;

public class OrderModel extends BaseModel {

    public Observable<Result<PayParam>> createHashOrder(int payMode, int count, BigDecimal price, BigDecimal amount, String id) {
        return OrderHttpUtil.createHashOrder(payMode, count, price, amount, id).compose(RxSchedulers.ioMain());
    }


    public Observable<Result<PayParam>> odinPay(String tradeNo, String password) {
        return OrderHttpUtil.odinPay(tradeNo, MD5Util.md5encode(password, "UTF-8")).compose(RxSchedulers.ioMain());
    }

    public Observable<Result<List<Order>>> getOrders(int type, int status, int pageNum) {
        return OrderHttpUtil.getOrders(type, status, pageNum).compose(RxSchedulers.ioMain());
    }


    public Observable<Result> cancelOrder(String tradeNo) {
        return OrderHttpUtil.cancelOrder(tradeNo).compose(RxSchedulers.ioMain());
    }

    public Observable<Result<List<Order>>> rechargeRecord() {
        return UserHttpUtil.rechargeRecord().compose(RxSchedulers.ioMain());
    }

    public Observable<Result<Order>> getRechargeDetail(String orderId) {
        return UserHttpUtil.getRechargeDetail(orderId).compose(RxSchedulers.ioMain());
    }

    public Observable<Result<RechargeInfo>> getRechargeAddress() {
        return OtherHttpUtil.getRechargeAddress().compose(RxSchedulers.ioMain());
    }

}
